package poo.alberi;

import java.util.LinkedList;

public class BNode<E> implements Nodo<E> {

	private E elem;
	private BNode<E> parent;
	private BNode<E> left;
	private BNode<E> right;

	public BNode(E e, BNode<E> p) {
		elem = e;
		parent = p;
	}

	public E getElement() {
		return elem;
	}

	public void setElement(E e) {
		elem = e;
	}

	public BNode<E> getParent() {
		return parent;
	}

	public void setParent(Nodo<E> p) {
		parent = (BNode<E>) p;

	}

	public BNode<E> getLeft() {
		return left;
	}

	public void setLeft(BNode<E> l) {
		left = l;
	}

	public BNode<E> getRight() {
		return right;
	}

	public void setRight(BNode<E> r) {
		right = r;
	}

	public LinkedList<Nodo<E>> getChildren() {

		LinkedList<Nodo<E>> l = new LinkedList<Nodo<E>>();

		if (left != null)
			l.add(left);
		if (right != null)
			l.add(right);
		return l;
	}
}
